﻿<!-- #include file="ding.asp" -->
<!-- #include file="mymin.asp" -->
<%Call Head()
w "<card title='处理WML页面'><p>"
  
IF KEY<>0 then Call Error("你的权限不足！")

dim id,lxl,class1,url,Wmlname,wmltxt
id=request("id")
if id="" or IsNumeric(id)=False then ID=0
url=request.form("url")
Wmlname=request.form("Wmlname")
wmltxt=request.form("wmltxt")
if wmltxt="" then Call Error("WML页面内容不能为空！")

active=request.form("active")
if active="" or IsNumeric(active)=False then active=0
lxl= cint(request("lxl"))
class1=request("class1")
relid=request("relid")
num=request("num")
if class1="" then Call Error("栏目名称不能为空！")

if relid="" or IsNumeric(relid)=False then num=0
if num="" or IsNumeric(num)=False then num=0
pid=request.form("pid")
if pid="" or IsNumeric(pid)=False then Call Error("排序无效！")

br=request.form("br")
if br="" or IsNumeric(br)=False then Call Error("换行无效！")
lx=request.form("lx")
if lx="" or IsNumeric(lx)=False then  Call Error("类型无效！")
parent=request.form("parent")
if parent="" or IsNumeric(parent)=False then parent=0
lid=request.form("lid")
if lid <>"" then if IsNumeric(lid)=False then Call Error("ID无效！")


dim reads,fso,filesize
if url<>"" then
	filename=url
else
	if Wmlname="" then
		filename="/wml/"&addwml(now())
	else
		filename="/wml/"&Wmlname&".wml"
	end if
end if
reads=LoadFile("74hu/wml.txt")
call SaveToFile(reads&wmltxt,filename)
Set fso = server.CreateObject("Scripting.FileSystemObject")
filesize=fso.GetFile(Server.MapPath(filename)).size
set rs=server.createobject("adodb.recordset")
if url<>"" then
	sql="select * from class where classid="&id 
else
	sql="select * from class" 
end if
rs.open sql,myconn,2,3
if url="" then rs.addnew
rs("class")=class1
rs("pid")=pid
rs("br")=br
rs("lx")=lx
if parent<>0 then rs("parent")=parent
rs("url")=filename
rs("active")=active
rs.update
rs.close
set rs=nothing
if url<>"" then
	w "WML页面编辑成功！"
else
	w "WML页面添加成功！"
end if%>
<br/>预览WML<a href='<%=filename%>'><%=filename%></a><br/>
<%if id<>0 then %>
<a href="Clist.asp?sid=<%=sid%>&amp;id=<%=id%>&amp;lx=20">[栏目分类]</a><br/>
<%end if%>
<a href='class.asp?sid=<%=sid%>'>[栏目分类]</a><%call rootLast%>